﻿using System;
using System.Collections.Generic;
using System.Drawing;
using RaytracerLib.Layers;
using RaytracerLib.MathLib;
using TomanuExtensions;
using RaytracerLib.Layers.OverlayCorrectors;
using System.Linq;
using RaytracerLib.Postprocessing;
using System.Diagnostics;
using RaytracerLib.Renderers;

namespace RaytracerLib.Resamplers
{
    public abstract class InterpolateResampler : FilterResampler
    {
        protected PixelInterpolator[,] m_pixels;
        protected OverlayCorrector m_overlay_corrector;

        protected override ColorFloat ResamplePixel(int a_x, int a_y)
        {
            return Gamma.SRGBToLinear(m_pixels[a_x, a_y].Color);
        }

        internal override void RenderStart(RenderStartPhase a_phase)
        {
            if (a_phase == RenderStartPhase.PrepareObjectToRender)
            {
                m_pixels = new PixelInterpolator[Film.Width, Film.Height];
                m_overlay_corrector = OverlayCorrector.Create(
                    OverlayMethod.Mirror, Film.Width, Film.Height, Filter.Ray.Ceiling());
            }
        }
    }
}